# -*- coding:utf8 -*-
# !/usr/bin/python
'''
author: ning.luo
createTime: 2021/4/2 15:02
update: ning.luo
updateTime: 2021/4/2 15:02
description: 文件简介描述
'''

import re

class logConversation:

    def read_log(self):
        file_name = './infra_deploy-cass-webagent(1).log'
        with open(file_name, 'r', encoding='utf-8') as f:
            for line in f.readlines():
                line = line.strip()
                # print(line)
                req_type = re.search('GET|POST|PUT|DELETE', line, re.I)
                if req_type:
                    req_type = req_type.group()
                    print('类型：', req_type)
                else:
                    print('类型匹配失败！')
                url_path = re.search('/(.*)\s*HTTP', line, re.I)
                if url_path:
                    url_path = url_path.group()
                    url = url_path.split(' ')[0]
                    print('路径：', url)
                else:
                    print('路径匹配失败！')
                req_query = re.search(r'(?<=\$\$).*?(?=\$\$)', line)
                if req_query:
                    req_query = req_query.group()
                    print('参数：', req_query)
                else:
                    print('参数为空！')
                userId = re.search(r'\]\s*([^\]\-\s]*)\s*\-\s*"', line)
                if userId:
                    userId = userId.group(1)
                    print('用户id：', userId)
                else:
                    print('用户id为空！')
                print('-------------------')

    def




if __name__ == '__main__':
    log_file = logConversation()
    log_file.read_log()

